package com.hq.service;

import com.hq.bean.House;
import com.hq.bean.User;
import com.hq.dao.HouseDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class HouseServiceImpl implements HouseService{
    @Resource
    private HouseDao houseDao;
    @Override
    public List list(Map map) {
        return houseDao.list(map);
    }

    @Override
    public int add(House house, Integer[] mids) {
        //添加主表
        int i = houseDao.add(house);
        //添加中间
        if (mids!=null && mids.length>0){
            Map map = new HashMap();
            map.put("hid",house.getHid());
            map.put("mids",mids);
            houseDao.addzhong(map);
        }
        return i;
    }

    @Override
    public int del(Integer hid) {
        //删除主表
        int i = houseDao.del(hid);
        //删除中间
        houseDao.delzhong(hid);
        return i;
    }

    @Override
    public User login(User user) {
        return houseDao.login(user);
    }
}
